import functools


class Solution(object):
    @functools.cache
    def beautifulArray(self, n):
        if n == 1:
            return [1]
        left = self.beautifulArray((n + 1) // 2).copy()
        right = self.beautifulArray(n // 2).copy()
        left = [2 * v - 1 for v in left]
        right = [2 * v for v in right]
        return left + right





data = Solution()
n = 10
print(data.beautifulArray(n))
